<template>
  <view class="trust-features-menu">
    <view class="menu-header">
      <text class="menu-title">信任功能</text>
      <text class="menu-subtitle">探索更多玩法</text>
    </view>
    
    <view class="features-grid">
      <view 
        v-for="feature in visibleFeatures" 
        :key="feature.id"
        class="feature-card"
        @click="handleFeatureClick(feature.id)"
      >
        <view class="feature-icon" :class="feature.type">
          <text class="icon">{{ feature.icon }}</text>
        </view>
        <text class="feature-name">{{ feature.name }}</text>
      </view>
      
      <view class="feature-card more-features" @click="showMoreFeatures">
        <view class="feature-icon">
          <text class="icon">⋯</text>
        </view>
        <text class="feature-name">更多功能</text>
      </view>
    </view>
    
    <!-- 更多功能弹窗 -->
    <view v-if="showMoreModal" class="more-features-modal" @click="closeMoreFeatures">
      <view class="modal-content" @click.stop>
        <view class="modal-header">
          <text class="modal-title">更多功能</text>
          <view class="close-btn" @click="closeMoreFeatures">
            <text class="close-icon">×</text>
          </view>
        </view>
        
        <view class="modal-body">
          <view 
            v-for="feature in hiddenFeatures" 
            :key="feature.id"
            class="feature-item"
            @click="handleFeatureClick(feature.id)"
          >
            <view class="feature-icon" :class="feature.type">
              <text class="icon">{{ feature.icon }}</text>
            </view>
            <view class="feature-info">
              <text class="feature-name">{{ feature.name }}</text>
              <text class="feature-desc">{{ feature.description }}</text>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'TrustFeaturesMenu',
  data() {
    return {
      showMoreModal: false,
      features: [
        {
          id: 'trust_cards',
          name: '信任卡牌',
          icon: '🃏',
          type: 'trust',
          description: '管理你的信任卡牌'
        },
        {
          id: 'dashboard',
          name: '仪表盘',
          icon: '📊',
          type: 'stats',
          description: '查看游戏数据统计'
        },
        {
          id: 'achievements',
          name: '成就',
          icon: '🏆',
          type: 'achievement',
          description: '查看信任成就'
        },
        {
          id: 'trust_history',
          name: '信任历史',
          icon: '📜',
          type: 'history',
          description: '查看信任行为记录'
        },
        {
          id: 'trust_analysis',
          name: '信任分析',
          icon: '🔍',
          type: 'analysis',
          description: '分析信任模式'
        },
        {
          id: 'trust_settings',
          name: '信任设置',
          icon: '⚙️',
          type: 'settings',
          description: '调整信任参数'
        }
      ]
    }
  },
  computed: {
    visibleFeatures() {
      return this.features.slice(0, 3)
    },
    hiddenFeatures() {
      return this.features.slice(3)
    }
  },
  methods: {
    handleFeatureClick(featureId) {
      this.$emit('feature-click', featureId)
      this.closeMoreFeatures()
    },
    
    showMoreFeatures() {
      this.showMoreModal = true
    },
    
    closeMoreFeatures() {
      this.showMoreModal = false
    }
  }
}
</script>

<style scoped>
.trust-features-menu {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16rpx;
  padding: 20rpx;
  margin: 16rpx 0;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}

.menu-header {
  text-align: center;
  margin-bottom: 20rpx;
}

.menu-title {
  font-size: 24rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 4rpx;
}

.menu-subtitle {
  font-size: 14rpx;
  color: #666;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16rpx;
}

.feature-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8rpx;
  padding: 16rpx;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12rpx;
  border: 1rpx solid rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
}

.feature-card:active {
  transform: scale(0.95);
  background: rgba(0, 123, 255, 0.1);
}

.feature-card.more-features {
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.1), rgba(0, 123, 255, 0.2));
  border: 1rpx solid rgba(0, 123, 255, 0.3);
}

.feature-icon {
  width: 40rpx;
  height: 40rpx;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 123, 255, 0.1);
  border: 1rpx solid rgba(0, 123, 255, 0.3);
}

.feature-icon.trust {
  background: rgba(40, 167, 69, 0.1);
  border-color: rgba(40, 167, 69, 0.3);
}

.feature-icon.stats {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
}

.feature-icon.achievement {
  background: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.3);
}

.icon {
  font-size: 20rpx;
}

.feature-name {
  font-size: 14rpx;
  font-weight: bold;
  color: #333;
  text-align: center;
}

/* 更多功能弹窗 */
.more-features-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #ffffff;
  border-radius: 16rpx;
  width: 90%;
  max-width: 600rpx;
  max-height: 80%;
  overflow: hidden;
  border: 1rpx solid rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20rpx;
  border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
}

.modal-title {
  font-size: 20rpx;
  font-weight: bold;
  color: #333;
}

.close-btn {
  width: 32rpx;
  height: 32rpx;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.close-icon {
  font-size: 18rpx;
  color: #666;
}

.modal-body {
  padding: 20rpx;
  max-height: 400rpx;
  overflow-y: auto;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 16rpx;
  padding: 16rpx;
  background: #f8f9fa;
  border-radius: 12rpx;
  margin-bottom: 12rpx;
  border: 1rpx solid #e9ecef;
  transition: all 0.3s ease;
  cursor: pointer;
}

.feature-item:active {
  background: #e3f2fd;
  border-color: #2196f3;
  box-shadow: 0 4rpx 16rpx rgba(33, 150, 243, 0.2);
}

.feature-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4rpx;
}

.feature-item .feature-name {
  font-size: 16rpx;
  font-weight: bold;
  color: #333;
  text-align: left;
}

.feature-desc {
  font-size: 12rpx;
  color: #666;
}

/* 移动端优化 */
@media (max-width: 768rpx) {
  .trust-features-menu {
    padding: 12rpx;
    margin: 8rpx 0;
  }
  
  .menu-title {
    font-size: 18rpx;
  }
  
  .menu-subtitle {
    font-size: 12rpx;
  }
  
  .features-grid {
    gap: 8rpx;
  }
  
  .feature-card {
    padding: 12rpx;
    min-height: 60rpx;
  }
  
  .feature-icon {
    width: 24rpx;
    height: 24rpx;
    font-size: 16rpx;
  }
  
  .feature-name {
    font-size: 12rpx;
  }
  
  .modal-content {
    width: 95%;
  }
  
  .modal-header {
    padding: 16rpx;
  }
  
  .modal-title {
    font-size: 18rpx;
  }
  
  .modal-body {
    padding: 16rpx;
  }
  
  .feature-item {
    padding: 12rpx;
    gap: 12rpx;
  }
  
  .feature-item .feature-name {
    font-size: 14rpx;
  }
  
  .feature-desc {
    font-size: 10rpx;
  }
}
</style>

